package main

import (
	"fmt"
	"reflect"
)

func main() {
	name := "san"
	namePtr := &name
	fmt.Println(reflect.TypeOf(name))    // string
	fmt.Println(reflect.TypeOf(namePtr)) // *string
	fmt.Println("name变量的内存地址对应的值为:", *namePtr)
	fmt.Println("name变量的值为", namePtr)
	// var intP *int
	// fmt.Println("intP的指针类型为:", reflect.TypeOf(intP))
	// intP = &name
	// fmt.Println(intP)
	*namePtr = "san"
	fmt.Println("name变量的值为:", name)
	fmt.Println("name变量的内存地址对应的值为:", namePtr)

	demo1()
}

func demo1() {
	age := 18
	modifyAge(age)
	fmt.Println("age的值为:", age) // 18
	modifyAgePointer(&age)
	fmt.Println("age的值为:", age) // 20

}

// modifyAge 中的 age 只是实参 age 的一份拷贝
func modifyAge(age int) {
	age = 20
}

func modifyAgePointer(age *int) {
	*age = 20
}
